<template>
  <div>
    <V-CommonHeaderLeft>
      <div id="app">
        <el-row>
          <!-- 头部 -->
          <div class="header">
            <el-col :span="4" class="header-nav">
              <router-link to="/">首页&nbsp;&nbsp;/</router-link>
              <router-link to="/">应用&nbsp;&nbsp;/</router-link>
              <router-link to="/">开放订货平台</router-link>
            </el-col>
            <el-col :span="1" :offset="18">
              <img src alt class="shuImg">
            </el-col>
          </div>
        </el-row>
        <div class="contents">
          <h3>|设置登录页显示方式</h3>
          <el-radio v-model="radio" label="1" style="margin-left:30px" @click.native="focus()">焦点图模式</el-radio>
          <el-radio v-model="radio" label="2" @click.native="toggImg()">全屏图模式</el-radio>
          <div class="uploadFocus" v-show="showFocus">
            <el-upload
              class="avatar-uploader"
              action="https://jsonplaceholder.typicode.com/posts/"
              :show-file-list="false"
              :on-success="handleAvatarSuccess"
              :before-upload="beforeAvatarUpload"
            >
              <img v-if="imageUrl" :src="imageUrl" class="avatar">
              <i v-else class="el-icon-plus avatar-uploader-icon"></i>
              <div class="foucsFile">
                <div class="focusFile-header">
                  <img src="./../../../static/images/fileImg.png">
                  <p>
                    <span>点击上传焦点图</span>
                    <span>建议尺寸：600px * 600px，文件小于3M</span>
                  </p>
                </div>
              </div>
            </el-upload>
            <div class="spanInp">
              <span>链接地址</span>
              <input type="text" name id v-model="text">
            </div>
          </div>

          <div class="uploadFocus" v-show="showImg">
            <el-upload
              class="avatar-uploader"
              action="https://jsonplaceholder.typicode.com/posts/"
              :show-file-list="false"
              :on-success="handleAvatarSuccess2"
              :before-upload="beforeAvatarUpload2"
            >
              <img v-if="imageUrl2" :src="imageUrl2" class="avatar">
              <i v-else class="el-icon-plus avatar-uploader-icon"></i>
              <div class="foucsFile">
                <div class="focusFile-header">
                  <img src="./../../../static/images/fileImg.png">
                  <p>
                    <span>点击上传焦点图</span>
                    <span>建议尺寸：600px * 600px，文件小于3M</span>
                  </p>
                </div>
              </div>
            </el-upload>
          </div>
        </div>
        <div class="footer">
          <button>保存</button>
        </div>
      </div>
    </V-CommonHeaderLeft>
  </div>
</template>

<script>
import VCommonHeaderLeft from './../common/vCommonHeaderLeft/VCommonHeaderLeft'
export default {
  components: {
    VCommonHeaderLeft
  },
  data () {
    return {
      radio: '1',
      imageUrl: require('./../../../static/images/defalut_focus_screen_bg.jpg'),
      text: 'https://www.ysdinghuo.com',
      showFocus: true,
      showImg: false,
      imageUrl2: require('./../../../static/images/defalut_focus_screen_bg.jpg')
    }
  },
  methods: {
    handleAvatarSuccess (res, file) {
      this.imageUrl = URL.createObjectURL(file.raw)
    },
    beforeAvatarUpload (file) {
      const isJPG = file.type === 'image/jpeg'
      const isLt2M = file.size / 1024 / 1024 < 2

      if (!isJPG) {
        this.$message.error('上传头像图片只能是 JPG 格式!')
      }
      if (!isLt2M) {
        this.$message.error('上传头像图片大小不能超过 2MB!')
      }
      return isJPG && isLt2M
    },

    handleAvatarSuccess2 (res2, file2) {
      this.imageUrl2 = URL.createObjectURL(file2.raw)
    },
    beforeAvatarUpload2 (file2) {
      const isJPG = file2.type === 'image/jpeg'
      const isLt2M = file2.size / 1024 / 1024 < 2

      if (!isJPG) {
        this.$message.error('上传头像图片只能是 JPG 格式!')
      }
      if (!isLt2M) {
        this.$message.error('上传头像图片大小不能超过 2MB!')
      }
      return isJPG && isLt2M
    },
    focus () {
      this.showFocus = true
      this.showImg = false
    },
    toggImg () {
      this.showFocus = false
      this.showImg = true
    }
  }
}
</script>

<style lang="scss" scoped>
#app {
  width: 100%;
  background-color: #f2f5f7;
  height: 100%;
  padding: 15px 10px 0px 10px;
}
.header {
  height: 45px;
  .header-nav {
    line-height: 30px;
    font-size: 12px;
    display: flex;
    justify-content: space-around;
    padding-left: 10px;
    span {
      display: inline-block;
      margin-left: 10px;
    }
    a {
      color: #999999;
    }
    a:hover {
      color: #20ade5;
    }
  }
  .header-img {
    width: 25px;
    height: 25px;
    border-radius: 5px;
    border: 1px solid #dce4e7;
  }
}
.header-nav a:nth-child(3) {
  color: #333;
}
.header-nav a:nth-child(3):hover {
  color: #333;
}
.shuImg {
  width: 20px;
  height: 20px;
  border: 1px solid;
}
.contents {
  padding: 30px 10px 0px 10px;
  height: 420px;
  background-color: #fff;
  overflow-x: hidden;
  overflow-y: scroll;
}
.contents > h3 {
  font-size: 16px;
  width: 100%;
  margin-bottom: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid #e3e3e3;
}
.uploadFocus {
  padding-top: 20px;
}
.avatar-uploader .el-upload {
  border: 1px dashed #d9d9d9;
  border-radius: 6px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}
.avatar-uploader .el-upload:hover {
  border-color: #409eff;
}
.avatar-uploader-icon {
  font-size: 28px;
  color: #8c939d;
  width: 178px;
  height: 178px;
  line-height: 178px;
  text-align: center;
}
.avatar {
  width: 1000px;
  height: 570px;
  display: block;
  margin-left: 100px;
  box-shadow: 0px 0px 10px 5px #eeeeee;
}
.focusFile-header {
  display: flex;
  margin: 20px 0px 30px 90px;
}
.focusFile-header > img {
  margin-right: 10px;
}
.focusFile-header > p span:nth-child(1) {
  font-size: 22px;
  font-weight: lighter;
}
.focusFile-header > p span:nth-child(2) {
  font-size: 14px;
}
.focusFile-header > p span {
  display: block;
}
.spanInp {
  padding-bottom: 50px;
}
.spanInp > input {
  width: 540px;
  height: 40px;
  border: 1px solid #e3e3e3;
  text-indent: 1em;
  margin-left: 10px;
}
.spanInp > input::placeholder {
  font-size: 12px;
}
.spanInp > span {
  font-size: 12px;
  color: #666666;
  margin-left: 90px;
}
.spanInp > input:hover {
  border-color: #20ade5;
}
.footer {
  width: 100%;
  background-color: #fff;
  border-top: 1px solid #e3e3e3;
  height: 60px;
}
.footer > button {
  width: 155px;
  height: 45px;
  background-color: #20ade5;
  font-size: 12px;
  color: #fff;
  border: 0;
  text-align: center;
  line-height: 45px;
  float: right;
  margin: 10px 15px 0px 0px;
  border-radius: 5px;
  cursor: pointer;
}
</style>
